package com.deuwise.config;

import com.qiwo.common.utils.SpringContextHolder;
import com.qiwo.common.utils.UploadProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

/**
 * Copyright
 *
 * @author chenwenchao
 * @date 2019/7/17
 * Description:设置读取图片路径
 */
@Configuration
public class GoWebMvcConfigurerAdapter extends WebMvcConfigurationSupport {

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        UploadProperties uploadProperties= SpringContextHolder.getBean(UploadProperties.class);
        //配置静态资源处理
        registry.addResourceHandler("/**")
                .addResourceLocations("classpath:/META-INF/resources/","classpath:/resources/", "classpath:/static/", "classpath:/public/","file:"+uploadProperties.getBasePath());
    }
}
